// Created from GenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Reflection;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.Generated.AbstractMessage;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using TX = System.String;
using FT = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class SIU_S14 : AbstractMessage
    {
		/// Constructor
		public SIU_S14() : base()
        {
			if (MSH != null) {
                MSH.MessageType = new MSG() { MessageCode = "SIU", TriggerEvent = "S14" };
			}
        }

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("SCH",2)]
  	    [HL7Field(HL7Version.v23, 2, HL7Repeat.False, HL7Required.True,"SCH")]
  	    [HL7Field(HL7Version.v231, 2, HL7Repeat.False, HL7Required.True,"SCH")]
  	    [HL7Field(HL7Version.v24, 2, HL7Repeat.False, HL7Required.True,"SCH")]
  	    [HL7Field(HL7Version.v25, 2, HL7Repeat.False, HL7Required.True,"SCH")]
  	    [HL7Field(HL7Version.v251, 2, HL7Repeat.False, HL7Required.True,"SCH")]
  	    [HL7Field(HL7Version.v26, 2, HL7Repeat.False, HL7Required.True,"SCH")]
  	    [HL7Field(HL7Version.v27, 2, HL7Repeat.False, HL7Required.True,"SCH")]
	    public SCH SCH {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("NTE",5)]
  	    [HL7Field(HL7Version.v23, 5, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v231, 5, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v24, 5, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v25, 4, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v251, 4, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v26, 4, HL7Repeat.True, HL7Required.False,"NTE")]
  	    [HL7Field(HL7Version.v27, 4, HL7Repeat.True, HL7Required.False,"NTE")]
	    public NTE[] NTE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PATIENT",8)]
  	    [HL7Field(HL7Version.v23, 8, HL7Repeat.False, HL7Required.False,"PATIENT_SIU_S14")]
  	    [HL7Field(HL7Version.v231, 8, HL7Repeat.False, HL7Required.False,"PATIENT_SIU_S12")]
  	    [HL7Field(HL7Version.v24, 8, HL7Repeat.False, HL7Required.False,"PATIENT_SIU_S12")]
  	    [HL7Field(HL7Version.v25, 5, HL7Repeat.True, HL7Required.False,"PATIENT_SIU_S12")]
  	    [HL7Field(HL7Version.v251, 5, HL7Repeat.True, HL7Required.False,"PATIENT_SIU_S12")]
  	    [HL7Field(HL7Version.v26, 5, HL7Repeat.True, HL7Required.False,"PATIENT_SIU_S12")]
  	    [HL7Field(HL7Version.v27, 5, HL7Repeat.True, HL7Required.False,"PATIENT_SIU_S12")]
	    public PATIENT_SIU_S14[] PATIENT {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("RESOURCES",29)]
  	    [HL7Field(HL7Version.v23, 29, HL7Repeat.True, HL7Required.True,"RESOURCES_SIU_S14")]
  	    [HL7Field(HL7Version.v231, 32, HL7Repeat.True, HL7Required.True,"RESOURCES_SIU_S12")]
  	    [HL7Field(HL7Version.v24, 32, HL7Repeat.True, HL7Required.True,"RESOURCES_SIU_S12")]
  	    [HL7Field(HL7Version.v25, 14, HL7Repeat.True, HL7Required.True,"RESOURCES_SIU_S12")]
  	    [HL7Field(HL7Version.v251, 13, HL7Repeat.True, HL7Required.True,"RESOURCES_SIU_S12")]
  	    [HL7Field(HL7Version.v26, 14, HL7Repeat.True, HL7Required.True,"RESOURCES_SIU_S12")]
  	    [HL7Field(HL7Version.v27, 13, HL7Repeat.True, HL7Required.True,"RESOURCES_SIU_S12")]
	    public RESOURCES_SIU_S14[] RESOURCES {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("GENERAL_RESOURCE",41)]
  	    [HL7Field(HL7Version.v23, 41, HL7Repeat.False, HL7Required.False,"GENERAL_RESOURCE_SIU_S14")]
  	    [HL7Field(HL7Version.v231, 44, HL7Repeat.False, HL7Required.False,"GENERAL_RESOURCE_SIU_S12")]
  	    [HL7Field(HL7Version.v24, 44, HL7Repeat.False, HL7Required.False,"GENERAL_RESOURCE_SIU_S12")]
	    public GENERAL_RESOURCE_SIU_S14 GENERAL_RESOURCE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("LOCATION_RESOURCE",51)]
  	    [HL7Field(HL7Version.v23, 51, HL7Repeat.False, HL7Required.False,"LOCATION_RESOURCE_SIU_S14")]
  	    [HL7Field(HL7Version.v231, 54, HL7Repeat.False, HL7Required.False,"LOCATION_RESOURCE_SIU_S12")]
  	    [HL7Field(HL7Version.v24, 54, HL7Repeat.False, HL7Required.False,"LOCATION_RESOURCE_SIU_S12")]
	    public LOCATION_RESOURCE_SIU_S14 LOCATION_RESOURCE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PERSONNEL_RESOURCE",61)]
  	    [HL7Field(HL7Version.v23, 61, HL7Repeat.False, HL7Required.False,"PERSONNEL_RESOURCE_SIU_S14")]
  	    [HL7Field(HL7Version.v231, 64, HL7Repeat.False, HL7Required.False,"PERSONNEL_RESOURCE_SIU_S12")]
  	    [HL7Field(HL7Version.v24, 64, HL7Repeat.False, HL7Required.False,"PERSONNEL_RESOURCE_SIU_S12")]
	    public PERSONNEL_RESOURCE_SIU_S14 PERSONNEL_RESOURCE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("TQ1",3)]
  	    [HL7Field(HL7Version.v25, 3, HL7Repeat.True, HL7Required.False,"TQ1")]
  	    [HL7Field(HL7Version.v251, 3, HL7Repeat.True, HL7Required.False,"TQ1")]
  	    [HL7Field(HL7Version.v26, 3, HL7Repeat.True, HL7Required.False,"TQ1")]
  	    [HL7Field(HL7Version.v27, 3, HL7Repeat.True, HL7Required.False,"TQ1")]
	    public TQ1[] TQ1 {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override Stack<string> ConsumeTextSegments(Stack<string> availableData, HL7ParserOptions options) {

				if (HL7Version.v23 == options.Version) {
		 SCH = PopSegmentParseAndCheckRequired<SCH>(availableData, options, "SCH");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 PATIENT = ProcessGroupArray<PATIENT_SIU_S14>(availableData, options, "PATIENT");
		 RESOURCES = ProcessGroupArray<RESOURCES_SIU_S14>(availableData, options, "RESOURCES");
		 GENERAL_RESOURCE = ProcessGroup<GENERAL_RESOURCE_SIU_S14>(availableData, options, "GENERAL_RESOURCE");
		 LOCATION_RESOURCE = ProcessGroup<LOCATION_RESOURCE_SIU_S14>(availableData, options, "LOCATION_RESOURCE");
		 PERSONNEL_RESOURCE = ProcessGroup<PERSONNEL_RESOURCE_SIU_S14>(availableData, options, "PERSONNEL_RESOURCE");
		}
		if (HL7Version.v231 == options.Version) {
		 SCH = PopSegmentParseAndCheckRequired<SCH>(availableData, options, "SCH");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 PATIENT = ProcessGroupArray<PATIENT_SIU_S14>(availableData, options, "PATIENT");
		 RESOURCES = ProcessGroupArray<RESOURCES_SIU_S14>(availableData, options, "RESOURCES");
		 GENERAL_RESOURCE = ProcessGroup<GENERAL_RESOURCE_SIU_S14>(availableData, options, "GENERAL_RESOURCE");
		 LOCATION_RESOURCE = ProcessGroup<LOCATION_RESOURCE_SIU_S14>(availableData, options, "LOCATION_RESOURCE");
		 PERSONNEL_RESOURCE = ProcessGroup<PERSONNEL_RESOURCE_SIU_S14>(availableData, options, "PERSONNEL_RESOURCE");
		}
		if (HL7Version.v24 == options.Version) {
		 SCH = PopSegmentParseAndCheckRequired<SCH>(availableData, options, "SCH");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 PATIENT = ProcessGroupArray<PATIENT_SIU_S14>(availableData, options, "PATIENT");
		 RESOURCES = ProcessGroupArray<RESOURCES_SIU_S14>(availableData, options, "RESOURCES");
		 GENERAL_RESOURCE = ProcessGroup<GENERAL_RESOURCE_SIU_S14>(availableData, options, "GENERAL_RESOURCE");
		 LOCATION_RESOURCE = ProcessGroup<LOCATION_RESOURCE_SIU_S14>(availableData, options, "LOCATION_RESOURCE");
		 PERSONNEL_RESOURCE = ProcessGroup<PERSONNEL_RESOURCE_SIU_S14>(availableData, options, "PERSONNEL_RESOURCE");
		}
		if (HL7Version.v25 == options.Version) {
		 SCH = PopSegmentParseAndCheckRequired<SCH>(availableData, options, "SCH");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 PATIENT = ProcessGroupArray<PATIENT_SIU_S14>(availableData, options, "PATIENT");
		 RESOURCES = ProcessGroupArray<RESOURCES_SIU_S14>(availableData, options, "RESOURCES");
		 TQ1 = PopSegmentParseAndCheckRequiredArray<TQ1>(availableData, options, "TQ1");
		}
		if (HL7Version.v251 == options.Version) {
		 SCH = PopSegmentParseAndCheckRequired<SCH>(availableData, options, "SCH");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 PATIENT = ProcessGroupArray<PATIENT_SIU_S14>(availableData, options, "PATIENT");
		 RESOURCES = ProcessGroupArray<RESOURCES_SIU_S14>(availableData, options, "RESOURCES");
		 TQ1 = PopSegmentParseAndCheckRequiredArray<TQ1>(availableData, options, "TQ1");
		}
		if (HL7Version.v26 == options.Version) {
		 SCH = PopSegmentParseAndCheckRequired<SCH>(availableData, options, "SCH");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 PATIENT = ProcessGroupArray<PATIENT_SIU_S14>(availableData, options, "PATIENT");
		 RESOURCES = ProcessGroupArray<RESOURCES_SIU_S14>(availableData, options, "RESOURCES");
		 TQ1 = PopSegmentParseAndCheckRequiredArray<TQ1>(availableData, options, "TQ1");
		}
		if (HL7Version.v27 == options.Version) {
		 SCH = PopSegmentParseAndCheckRequired<SCH>(availableData, options, "SCH");
		 NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
		 PATIENT = ProcessGroupArray<PATIENT_SIU_S14>(availableData, options, "PATIENT");
		 RESOURCES = ProcessGroupArray<RESOURCES_SIU_S14>(availableData, options, "RESOURCES");
		 TQ1 = PopSegmentParseAndCheckRequiredArray<TQ1>(availableData, options, "TQ1");
		}
			if (availableData != null && availableData.Count > 0) {
				ConsumeZSegmentsFromText(availableData, options);
			}
            return availableData;
        
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "SIU_S14";
			}
        }

        static SIU_S14() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(SIU_S14));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
			if (MSH != null) {
				segmentData.Add(MSH.GetER7(options));
			}
			if (SCH != null) {
				segmentData.Add(SCH.GetER7(options));
			}
			if (NTE != null && NTE.Length > 0) {
				for (int i = 0; i < NTE.Length; i++) {
					segmentData.Add(NTE[i].GetER7(options));
				}
			}
			if (PATIENT != null && PATIENT.Length > 0) {
				for (int i = 0; i < PATIENT.Length; i++) {
					segmentData.Add(PATIENT[i].GetER7(options));
				}
			}
			if (RESOURCES != null && RESOURCES.Length > 0) {
				for (int i = 0; i < RESOURCES.Length; i++) {
					segmentData.Add(RESOURCES[i].GetER7(options));
				}
			}
			if (GENERAL_RESOURCE != null) {
				segmentData.Add(GENERAL_RESOURCE.GetER7(options));
			}
			if (LOCATION_RESOURCE != null) {
				segmentData.Add(LOCATION_RESOURCE.GetER7(options));
			}
			if (PERSONNEL_RESOURCE != null) {
				segmentData.Add(PERSONNEL_RESOURCE.GetER7(options));
			}
			if (TQ1 != null && TQ1.Length > 0) {
				for (int i = 0; i < TQ1.Length; i++) {
					segmentData.Add(TQ1[i].GetER7(options));
				}
			}
           segmentData.AddRange(GetZSegmentsER7(options));
		   return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }


    }
}

